import request from "@/utils/request";

/** 角色权限API */
class RoleAuthorizationAPI {
  /**
   * 角色授权接口，角色和菜单做关联
   * @param {String} roleCode 角色编码
   * @param {*} menuList 菜单集合
   */
  static setRoleAuthApi(roleCode: string, menuList: any[]) {
    return request({
      url: `/admin/sysRoleAuthorizations/${roleCode}`,
      method: "post",
      data: menuList,
    });
  }
  /**
   * 获取指定角色的菜单权限
   * @param {String} roleCode 角色编码
   * @param {int} resourceType 资源类型
   */
  static getAuthByRoleCodeApi(roleCode: string, resourceType: number) {
    return request({
      url: `/admin/sysRoleAuthorizations/${roleCode}/resourceType/${resourceType}`,
      method: "get",
    });
  }
  /**
   * 获取角色对应的菜单权限集合
   * @param {String} roleCode 角色编码
   */
  static getMenuAuthByRoleCodeApi(roleCode: string) {
    return request({
      url: `/admin/sysRoleAuthorizations/roleCode/${roleCode}/menus`,
      method: "get",
    });
  }
}

export default RoleAuthorizationAPI;